title building for VS %1
@echo year: %1 version: %2 path: %3 project: %4_v%2

IF DEFINED PROGRAMFILES(x86) (
REG QUERY HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%2.0\Setup\VS /v environmentpath
) else (
REG QUERY HKLM\SOFTWARE\Microsoft\VisualStudio\%2.0\Setup\VS /v environmentpath
)

IF %ERRORLEVEL% NEQ 0 (
@echo VisualStudio %2.0 is not installed, err level = %ERRORLEVEL%

rem exit /b 0
goto eof
)
cd %3

rmdir /s /q .\DesignPatternsSetup_v%2\Release
rmdir /s /q .\DesignPatternsSetup_v%2\Debug
rmdir /s /q .\DesignPatterns\obj
rmdir /s /q .\DesignPatterns\bin
rmdir /s /q .\DesignPatternsWizard\obj
rmdir /s /q .\DesignPatternsWizard\bin
rmdir /s /q .\FormTest\obj
rmdir /s /q .\FormTest\bin
rmdir /s /q .\Common\obj
rmdir /s /q .\Common\bin

IF DEFINED PROGRAMFILES(x86) (
call "%PROGRAMFILES(x86)%\Microsoft Visual Studio %2%.0\VC\vcvarsall.bat" x86
) else (
call "%PROGRAMFILES%\Microsoft Visual Studio %2%.0\VC\vcvarsall.bat" x86
)

rem call "C:\Program Files (x86)\Microsoft Visual Studio %2.0\VC\vcvarsall.bat" x86
rem dir

devenv designpatterns_v%2.sln  /rebuild "Release|x86" /project %4_v%2
rem pause
rem cls
IF %ERRORLEVEL% NEQ 0 (
color F1
@echo err level = %ERRORLEVEL%
rem exit /b 1
)
cd .\Misc